<!-- 推荐卡片 -->
<template>
  <div class="hot-recommend">
    <div class="hot-recommend-header">
      <p>{{ cardTitle }}</p>
      <div class="hot-recommend-classify">
        <div
          class="hot-recommend-classifyItem"
          v-for="(item, index) in cardOption"
          :key="index"
          :class="[defaultsChecked == item.value ? 'active' : '']"
          @click="checkedOption(item)"
        >
          {{ item.lable }}
        </div>
      </div>
    </div>
    <div class="hot-recommend-main">
      <slot></slot>
    </div>
    <div class="hot-recommend-footer">
      <el-icon size="16" style="padding-right:3px">
        <CaretBottom />
      </el-icon>
      查看更多
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, toRefs, onMounted } from "vue";
const props = defineProps({
  cardTitle: {
    type: String,
    defaults: "推荐卡片",
  },

  cardOption: {
    type: Array,
    defaults: () => [],
    required: true,
  },

  activeName: {
    type: String,
    defaults: "",
    required: true,
  },
});

const emit = defineEmits(["changeActive"]);

const defaultsChecked = ref("");

const checkedOption = (row: any) => {
  defaultsChecked.value = row.value;
  emit("changeActive", row);
};

onMounted(() => {
  defaultsChecked.value = props.activeName;
});
</script>
<style scoped lang="scss">
$titleColor: #ff0003;
.hot-recommend {
  margin-top: 20px;
  border-radius: 8px;
  box-sizing: border-box;
  padding: 15px;
  background-color: #fff;

  .hot-recommend-header {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;

    p {
      font-weight: 600;
      font-size: 26px;
      margin: 0px;
      padding-right: 50px;
      color: #2d2d2d;
    }

    .hot-recommend-classify {
      display: flex;
      justify-content: flex-start;
      .hot-recommend-classifyItem {
        margin-right: 40px;
        font-size: 16px;
        color: #2d2d2d;
        cursor: pointer;
      }

      .active {
        position: relative;
        z-index: 1;
        font-weight: 600;
        &:after {
          position: absolute;
          left: 0px;
          bottom: 1px;
          content: "";
          width: 100%;
          height: 6px;
          background: $titleColor;
          z-index: -1;
        }
      }
    }
  }

  .hot-recommend-main {
    margin-top: 20px;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .hot-recommend-footer {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #999;
    cursor: pointer;
  }
}
</style>